import { queryTaskListApi } from "@/api/task"
import { TaskDataDTO } from "@/api/task/types"

export function useTaskSearchHook() {
  const searchForm = ref<Partial<TaskDataDTO>>({})

  const taskList = ref<TaskDataDTO[]>([])
  const queryTaskList = async () => {
    const { success, data } = await queryTaskListApi(searchForm.value)
    if (success) {
      taskList.value = data
    }
  }
  return {
    searchForm,
    taskList,
    queryTaskList,
  }
}

export type UseTaskSearchHookOpt = ReturnType<typeof useTaskSearchHook>
